
<script lang="ts" setup>
import avatar from '@/assets/default.jpg'
import { reactive, ref } from 'vue';
const userInfo = ref(true)

const setUserInfo = () => {
  userInfo.value = !userInfo.value
}

const userInfoForm = reactive({
  name:'Alice',
  phoneNumber:'123****99',
  email:'a*******@example.com',
  createAt:'2024-11-28 14:46:35',
  updatedAt:'2024-11-28 14:46:35'
})

</script>


<template>
  <div class="user-info-main">
    <h2>个人信息</h2>
    <hr>
    <div class="user-info">
      <div class="user-detail" v-if="userInfo">
        <div class="info">
          <span>头像</span>
          <el-avatar :src="avatar" />
        </div>

        <div class="info">
          <span>用户名</span>
          <span>{{userInfoForm.name}}</span>
        </div>
        <div class="info">
          <span>邮箱</span>
          <span>{{ userInfoForm.email }}</span>
        </div>
        <div class="info">
          <span>手机号</span>
          <span>{{ userInfoForm.phoneNumber }}</span>
        </div>
        <div class="info">
          <span>创建时间</span>
          <span>{{ userInfoForm.createAt }}</span>
        </div>
        <div class="info">
          <span>最后更新时间</span>
          <span>{{ userInfoForm.updatedAt }}</span>
        </div>
      </div>

      <div class="user-detail" v-else>
        <div class="info">
          <span>头像</span>
          <el-upload
              action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
              list-type="picture-card"

            ></el-upload>
        </div>

        <div class="info">
          <span>用户名</span>
          <el-input v-model="userInfoForm.name" style="width: 240px" placeholder="Please input" />
        </div>

      </div>
    </div>
    <div class="set-user" v-if="userInfo">
      <el-button @click="setUserInfo">修改信息</el-button>
    </div>

    <div class="set-user" v-else>
      <el-button @click="setUserInfo">返回</el-button>
      <el-button>保存</el-button>
    </div>




  </div>
</template>

<style lang="scss" scoped>
.user-info-main {
  h2 {
    color: white;
  }
  .user-info {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 30px;
    align-items: center;
    color: white;
    .user-detail {
      display: flex;
      flex-direction: column;
      gap: 40px;
      .info {
        span{
          display: flex;
          align-items: center;
        }

        display: flex;
        justify-content: space-between;
        width: 500px;
      }
    }
  }

  .set-user{
    margin-top: 50px;
    width: 100%;
    display: flex;
    justify-content: center;
  }
}
</style>
